var add_crumbs = JSON.parse(sessionStorage.getItem('add_crumbs')) == null ? { meta: { title: '促销工具' }} : JSON.parse(sessionStorage.getItem('add_crumbs'))
var crumbs_two = JSON.parse(sessionStorage.getItem('crumbs_two')) == null ? { meta: { title: '' }} : JSON.parse(sessionStorage.getItem('crumbs_two'))

// console.log(add_crumbs)
const state = {
  crumbs: add_crumbs,
  // crumbs: {
  //   meta: {
  //     title: ''
  //   }
  // },
  crumbsTwo: crumbs_two,
  // crumbsTwo: {
  //   meta: {
  //     title: ''
  //   }
  // },
  pickerOptions: {
    shortcuts: [{
      text: '今天',
      onClick(picker) {
        const end = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 23, 59, 59)
        const start = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate())
        picker.$emit('pick', [start, end])
      }
    }, {
      text: '昨天',
      onClick(picker) {
        const end = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() - 1, 23, 59, 59)
        const start = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() - 1)
        picker.$emit('pick', [start, end])
      }
    }, {
      text: '近7天',
      onClick(picker) {
        const end = new Date()
        const start = new Date()
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
        picker.$emit('pick', [start, end])
      }
    }, {
      text: '最近一个月',
      onClick(picker) {
        const end = new Date()
        const start = new Date()
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
        picker.$emit('pick', [start, end])
      }
    }, {
      text: '最近三个月',
      onClick(picker) {
        const end = new Date()
        const start = new Date()
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
        picker.$emit('pick', [start, end])
      }
    }]
  }
}

const mutations = {
  ADD_CRUMBS: (state, log) => {
    state.crumbs = log
  },
  CRUMBS_TWO: (state, log) => {
    state.crumbsTwo = log
  }
}

export default {
  state,
  mutations
}
